//获取url上的请求参数
function getParams() {
    //获取问号及问号后面的内容
    var url = window.location.search;
    var params = new Object();
    if (url.indexOf("?") != -1) {
        //截取问号后面的内容,再使用&分割多个属性
        var arr = url.substr(1).split("&");
        for (var i = 0; i < arr.length; i++) {
            //使用=分割为keyvalue
            var keyValue = arr[i].split("=");
            params[keyValue[0]] = keyValue[1];
        }
    }
    return params;
}

var baseUrl = "http://localhost:8081";
$(function(){
    $.ajaxSetup({
        crossDomain: true, //是否允许跨域
        xhrFields: {withCredentials: true}//为true，发ajax请求时会带上跨域的cookie
    });
});

function getHref(item,value){
    var url = $(item).data("url") + value;
    $(item).attr("href",url);
}

function showComments(str) {
    var Mar = document.getElementsByClassName(str)[0];
    var child_div = Mar.getElementsByTagName("div");
    var picH = 50;//移动高度
    var scrollstep = 3;//移动步幅,越大越快
    var scrolltime = 20;//移动频度(毫秒)越大越慢
    var stoptime = 3000;//间断时间(毫秒)
    var tmpH = 0;
    Mar.innerHTML += Mar.innerHTML;
    function start() {
        if (tmpH < picH) {
            tmpH += scrollstep;
            if (tmpH > picH)tmpH = picH;
            Mar.scrollTop = tmpH;
            setTimeout(start, scrolltime);
        } else {
            tmpH = 0;
            Mar.appendChild(child_div[0]);
            Mar.scrollTop = 0;
            setTimeout(start, stoptime);
        }
    }

    setTimeout(start, stoptime)
}
jQuery.ajaxSettings.traditional = true;//让数组不添加[]

// 判断是否到底部
function isEnd() {
    return $(window).scrollTop() + $(window).height() >= $(document).height() -1;
}